<template>
  <div class="order">
    <van-panel title="订单号：51a5sa24ew1ew2ew1g" status="交易成功" class="order-panel">
      <van-card :title="goods.title" :desc="formatPrice()" :num="goods.num" :thumb="goods.thumb" />
      <div slot="footer" class="test">
        您可以去“
        <a>我的物品</a>”中查看兑换的内容
      </div>
    </van-panel>

    <van-submit-bar button-text="查看" button-type="default" class="order-action">
      <div slot="default" class="order-amount">
        实付：
        <span class="price">{{goods.price}}</span>
        <small>橙子</small>
      </div>
    </van-submit-bar>
  </div>
</template>
<script>
import {
  Tag,
  Col,
  Icon,
  Cell,
  CellGroup,
  Card,
  Button,
  Panel,
  NoticeBar,
  SubmitBar
} from 'vant'

export default {
  components: {
    [Tag.name]: Tag,
    [Col.name]: Col,
    [Icon.name]: Icon,
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
    [Panel.name]: Panel,
    [Card.name]: Card,
    [Button.name]: Button,
    [NoticeBar.name]: NoticeBar,
    [SubmitBar.name]: SubmitBar
  },
  data () {
    return {
      goods: {
        id: 1,
        title: '美国伽力果（约680g/3个）',
        price: 2680,
        express: '免运费',
        description: '简介',
        remain: 19,
        num: 1,
        material: true,
        content:
          '<h1>商品简介</h1>djdslkfkfdkjldsflkjsdskjldfskdfsdfsdfslkjdfslkjdfslkdfslkjdfslkjldsdfsdfsdfsklkjsd',
        thumb:
          'https://img.yzcdn.cn/public_files/2017/10/24/e5a5a02309a41f9f5def56684808d9ae.jpeg'
      }
    }
  },
  watch: {
    $route (to, from) {
      let isBack = this.$router.isBack //  监听路由变化时的状态为前进还是后退
      if (isBack) {
        console.log('isback')
      } else {
        console.log('noback')
      }
      this.$router.isBack = false
    }
  },
  methods: {
    submitForm () {
      this.axios
        .get('/site/index')
        .then(response => {
          this.msg = response.data.msg
        })
        .catch(function (error) {
          console.log(error)
        })
    },

    formatPrice () {
      return this.goods.price + '橙子'
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.order-panel /deep/ .van-panel__header {
  font-size: 0.2rem;
}
.order-panel /deep/ .van-cell__title {
  flex: 2;
  -webkit-box-flex: 2;
  text-transform: uppercase;
}
.order-panel /deep/ .van-panel__footer {
  font-size: 0.2rem;
}
.order-panel /deep/ .van-panel__footer a {
  color: #42b983;
}
.order-amount {
  text-align: left;
  padding-left: 0.3rem;
  font-size: 0.24rem;
}
.order-amount .price {
  color: #ff6600;
  font-size: 0.4rem;
}
.order-amount small {
  padding-left: 0.1rem;
  font-size: 85%;
  color: #aaa;
}
.order-action /deep/ button {
  display: none;
}
</style>
